package com.acme;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class SimpleItemAdapter extends ArrayAdapter<SimpleItem>{
	
	public SimpleItemAdapter(Context context, int textViewResourceId, SimpleItem[] items) {
		super(context, textViewResourceId, items);
	}
	
	@Override
    public View getView(int position, View convertView, ViewGroup parent) {
		
            View v = convertView;
            
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                //v = vi.inflate(R.layout.player_list_item, null);
                v = vi.inflate(R.layout.simple_item, parent, false);
            }
            
            SimpleItem item = getItem(position);
            if (item != null) {
            	
                TextView heading = (TextView) v.findViewById(android.R.id.text1);
                TextView details = (TextView) v.findViewById(android.R.id.text2);
                
                heading.setText(item.heading);
                details.setText(item.details);
            }
            return v;
    }
}
